package com.baor.controller;

import com.baor.domain.UserVo;
import com.baor.service.UserService;
import com.baor.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/insertUser")
    public AjaxResult<?> insertUser(@RequestBody UserVo userVo){
        return userService.insertUser(userVo);
    }

    @RequestMapping("/userList")
    public AjaxResult<?> userList(){
        return userService.userList(null);
    }

    @RequestMapping("/userInfo")
    public AjaxResult<?> userInfo(int userId){
        return userService.userInfo(userId);
    }

    @RequestMapping("/search")
    public AjaxResult<?> search(@RequestBody UserVo vo){
        return userService.userList(vo);
    }

    @RequestMapping("/update")
    public AjaxResult<?> update(@RequestBody UserVo vo){
        return userService.update(vo);
    }

    @RequestMapping("/delete")
    public AjaxResult<?> delete(@RequestBody UserVo vo){
        return userService.delete(vo.getUserId());
    }

    @RequestMapping("/resetPwd")
    public AjaxResult<?> resetPwd(@RequestBody UserVo vo){
        return userService.resetPwd(vo.getUserId());
    }

    @RequestMapping("/login")
    public AjaxResult<?> login(@RequestBody UserVo userVo){
        return userService.login(userVo);
    }

}
